﻿using System;
using System.ComponentModel;
using System.Data.SqlClient;
using APP.HELPER.Data.Helper;

namespace Dictionary.ERP
{
    public class HRM_PRODUCT_STATE
    {
        private string m_ProductCode;
        private string m_StateCode;

        public HRM_PRODUCT_STATE()
        {
            m_ProductCode = "";
            m_StateCode = "";
        }

        public HRM_PRODUCT_STATE(string ProductCode, string StateCode)
        {
            m_ProductCode = ProductCode;
            m_StateCode = StateCode;
        }

        [DisplayName("ProductCode"), Category("Column")]
        public string ProductCode
        {
            get { return m_ProductCode; }
            set { m_ProductCode = value; }
        }

        public string ProductName
        {
            get { return "Class HRM_PRODUCT_STATE"; }
        }

        public string ProductVersion
        {
            get { return "1.0.0.0"; }
        }

        [Category("Column"), DisplayName("StateCode")]
        public string StateCode
        {
            get { return m_StateCode; }
            set { m_StateCode = value; }
        }

        public string Delete()
        {
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {m_ProductCode, m_StateCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PRODUCT_STATE_Delete", myParams, myValues);
        }

        public string Delete(string ProductCode, string StateCode)
        {
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {ProductCode, StateCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PRODUCT_STATE_Delete", myParams, myValues);
        }

        public bool Exist(string ProductCode, string StateCode)
        {
            bool hasRows = false;
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {ProductCode, StateCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PRODUCT_STATE_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(string ProductCode, string StateCode)
        {
            string str = "";
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {ProductCode, StateCode};
            var helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PRODUCT_STATE_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    m_ProductCode = Convert.ToString(reader["ProductCode"]);
                    m_StateCode = Convert.ToString(reader["StateCode"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Insert()
        {
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {m_ProductCode, m_StateCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PRODUCT_STATE_Insert", myParams, myValues);
        }

        public string Insert(string ProductCode, string StateCode)
        {
            string[] myParams = {"@ProductCode", "@StateCode"};
            object[] myValues = {ProductCode, StateCode};
            var helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PRODUCT_STATE_Insert", myParams, myValues);
        }
    }
}